package com.example.lanouhn.bantangapp.activities.adapters;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.lanouhn.bantangapp.R;
import com.example.lanouhn.bantangapp.activities.contants.Useroriginal;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by lanouhn on 16/7/19.
 */
public class Adapter_FTogdeillist extends RecyclerView.Adapter<Adapter_FTogdeillist.MyViewHolder> {
    private Context context;
    List<Useroriginal> list;


    public Adapter_FTogdeillist(Context context, List<Useroriginal> list) {
        this.context = context;
        this.list = list;

    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.fragment_deillist_item,null);
        MyViewHolder viewHolder = new MyViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {

        holder.useroriginal_item_title.setText(list.get(position).getTitle());
        holder.useroriginal_item_center.setText(list.get(position).getViews());
        holder.useroriginal_item_textright.setText(list.get(position).getComments());
        holder.useroriginal_item_textleft.setText(list.get(position).getNickname());

      //图片
        Picasso.with(context).load(list.get(position).getPic()).into(holder.useroriginal_item_pic);

    }


    @Override
    public int getItemCount() {
        return list.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder{

        private ImageView useroriginal_item_pic;
        private TextView  useroriginal_item_title;
        private TextView useroriginal_item_center;
        private TextView   useroriginal_item_textright;
        private TextView   useroriginal_item_textleft;
        public MyViewHolder(View itemView) {
            super(itemView);
            useroriginal_item_pic = (ImageView) itemView.findViewById(R.id.useroriginal_item_pic);
            useroriginal_item_title= (TextView) itemView.findViewById(R.id.useroriginal_item_title);
            useroriginal_item_center= (TextView) itemView.findViewById(R.id.useroriginal_item_center);
            useroriginal_item_textright= (TextView) itemView.findViewById(R.id.useroriginal_item_textright);
            useroriginal_item_textleft = (TextView) itemView.findViewById(R.id.useroriginal_item_textleft);

        }
    }
}
